<template>
    <div>
        <h3>添加页面</h3>

        <thead>
            <table>
                <tr>
                    <td>
                        名称
                        <input type="text" v-model="obj.Ename">
                    </td>
                </tr>
                <tr>
                    <td>
                        性别
                        <input type="radio" name="sex" :value="1" >男
                        <input type="radio" name="sex" :value="2" >女
                    </td>
                </tr>
                <tr>
                    <td>
                        地址
                        <input type="text" v-model="obj.Eaddr">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button" value="添加" @click="Add">
                        <a href="/">返回列表</a>
                    </td>
                </tr>
            </table>
        </thead>
    </div>
</template>

<script setup lang="ts">

import {ref} from "vue"
import axios from "axios";
import {useRouter} from "vue-router"

const router=useRouter();

const obj=ref({
  "Ename": "",
  "Esex": 0,
  "Eaddr": ""
})

const Add=()=>{
    axios.post("https://localhost:7013/api/Emp/Add",obj.value).then(res=>{
    if(res.data>0)
    {
        alert("添加成功");
        router.push({name:'list'})
    }
    else
    {
        alert("添加失败");
    }
})
}

</script>

<style scoped>

</style>